% Reset all subclasses of dotsAllSingletonObjects.
% @param varargin arguments to pass to each singleton reset() method
% @details
% Invokes the reset() method of all of the subclasses of
% dotsAllSingletonObjects which are contained in Snow Dots.  @a varargin
% may contain property-value pairs to pass to each reset() method.  The
% reset() method of dotsAllSingletonObjects "knows" to ignore properties
% which are not defined for a particular subclass.
% @details
% Attempts to reset subclasses of dotsAllObjectManagers after resetting
% other singletons, in order to avoid initialization dependencies, or race
% conditions with remote servers.
% @details
% dotsResetTheSingletons() is provided for convenience, especially during
% unit testing.  Since multiple singleton subclasses may define properties
% with the same names, it may be necessary to set singleton proerties in a
% more nuanced way.  See dotsTheMachineConfiguaration.
function dotsResetTheSingletons(varargin)

% search for any concrete singleton subclasses
singletonFilter = 'dotsThe';
singletonFiles = findFiles(dotsRoot(), singletonFilter);

% search for dotsAllObjectManagers concrete subclasses
managerFilter = 'dotsThe.*Manager';
managerFiles = findFiles(dotsRoot(), managerFilter);

% reset non-managers first, with given arguments
nonManagerFiles = setdiff(singletonFiles, managerFiles);
sortedFiles = cat(2, nonManagerFiles, managerFiles);
for ii = 1:numel(sortedFiles)
    [classPath, className] = fileparts(sortedFiles{ii});
    resetter = str2func([className, '.reset']);
    feval(resetter, varargin{:});
end